import request from '@/utils/request'

/**
 * 录入学生和教师功能
 */

// 录入教师或学生接口
export const insertUser = (importUser) => {
  const { identify, id, name, collegeId, majorId, sex } = importUser
  return request.post('/admin/manage/insertUser', {
    identify,
    id,
    name,
    collegeId,
    majorId,
    sex
  })
}

// 分页查询接口
export const getUserList = (viewUser) => {
  const { pageNum, pageSize, id, name, collegeId, identify, status } = viewUser
  return request.get('/admin/manage/page', {
    params: {
      pageNum,
      pageSize,
      id,
      name,
      collegeId,
      identify,
      status
    }
  })
}

// 更新教师或学生信息接口
export const updateUser = (editUser) => {
  const { identify, id, name, collegeId, majorId, sex, status } = editUser
  return request.put('/admin/manage/updateUser', {
    identify,
    id,
    name,
    collegeId,
    majorId,
    sex,
    status
  })
}

// 根据教师或学生id查询详细信息接口
export const getUserDetail = (id, identify) => { return request.get(`/admin/manage/${id}/${identify}`) }

// 根据教师或学生id删除信息接口
export const deleteUser = (id, identify) => {
  return request.delete('/admin/manage/deleteUser', { params: { id, identify } })
}

// 批量新增教师或学生接口
export const uploadInsertExcel = (uploadFile) => {
  return request.post('/admin/manage/insertBatch', uploadFile, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 批量禁用教师或学生接口
export const uploadUpdateExcel = (uploadFile) => {
  return request.post('/admin/manage/updateBatch', uploadFile, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
